class Depend{
    constructor(){
        this.reactiveFns = []
    }
    addDepend(reactiveFn){
        this.reactiveFns.push(reactiveFn)
    }

    notify(){
        this.reactiveFns.forEach(fn=>{
            fn()
        })
    }
}






//封装一个响应式的函数
const depend = new Depend()
function watchFn(fn){
    depend.addDepend(fn)
}

//对象的响应式
const obj ={
    name:"why",
    age:18
}

watchFn(
    function foo(){
        const newName = obj.name
        console.log("你好，scott")
        console.log("Hello World")
        console.log(obj.name,'---foo') // 100行
    }
)
watchFn(function demo() {
    console.log(obj.name,'---demo')
})

obj.name = "kobe"
depend.notify()
